<template>
    <div style="width: 60%;color: #FFFFFF;margin-left: 20%">
      <h2 style="color: grey;margin-top: 20px">门户信息发布</h2><br>
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="信息标题">
          <el-input v-model="form.news_headline"></el-input>
        </el-form-item>

        <el-form-item label="副标题">
          <el-input v-model="form.news_subtitle" ></el-input>
        </el-form-item>


        <el-form-item label="信息内容">
          <el-input type="textarea" rows="17" v-model="form.news_content"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitNewsPortal">立即发布</el-button>
          <el-button @click="reset"> 重置</el-button>
        </el-form-item>
      </el-form>
    </div>
</template>

<style>
    body {
        background-color: #F5F5F5;
    }
</style>

<script>

    export default {
       name:'portalInfoRelease',
        data() {
          return {
            form: {
              news_headline: '',
              region: '',
              date1: '',
              date2: '',
              delivery: false,
              type: [],
              resource: '',
              desc: '',
              news_subtitle:'',
              news_content:''
            }
          }
        },
      methods: {
        submitNewsPortal() {

          this.$axios({
            url: `/api/manOperat/submitNewsPortal/` + "?news_headline=" + this.form.news_headline + "&news_subtitle=" + this.form.news_subtitle
            +"&news_content="+this.form.news_content,
            method: 'get',
          }).then(newsPortal => {  // 请求成功

            if(newsPortal.data != '发布成功'){
              alert("标题不能为空!");
            }else{
              alert("发布成功!");
              location.reload();
            }
          }).catch(error => {  // 请求失败
            alert("后台异常,请联系管理员!");
          });
        },
        reset(){
          this.form.news_headline = '';
          this.form.news_subtitle='';
          this.form.news_content = '';
        }
      },

    }
</script>
